
include('shared.lua')

local emitterDelay = 0.2

ENT.Emitter = nil
ENT.EmitterColour = nil
ENT.LastEmitted = 0

function ENT:Initialize()

	self.Emitter = ParticleEmitter( self:GetPos() )
	self.LastEmitted = CurTime() + 1

end

function ENT:Think()
	
	if ( self.LastEmitted < CurTime() ) then
	
		if ( self.EmitterColour == nil or self.EmitterColour == team.GetColor( TEAM_UNASSIGNED ) ) then
			self.EmitterColour = team.GetColor(self:GetTeam())
		end
		
		local particle = self.Emitter:Add("sprites/light_glow02_add", self:GetPos())
		particle:SetColor(self.EmitterColour.r, self.EmitterColour.g, self.EmitterColour.b, 255)
		particle:SetVelocity(Vector(math.random(-4,4),math.random(-4,4),math.random(-4,4)):GetNormal() * 20)
		particle:SetGravity(Vector(0,0,math.random(10, 40)))
		particle:SetDieTime(math.Rand(1, 2))
		particle:SetLifeTime(0)
		particle:SetStartSize(50)
		particle:SetEndSize(0)
		particle:SetStartAlpha(255)
		particle:SetEndAlpha(0)
		
		self.LastEmitted = CurTime() + emitterDelay
		
	end
end

function ENT:Draw()

	self:DrawModel()
	
end

